
@extends('public.father')

@section('css')


    <link href="/templates/hd/assets/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css"/>

    <link href="/templates/hd/assets/basic/css/demo.css" rel="stylesheet" type="text/css"/>
    <link href="/templates/hd/assets/css/cartstyle.css" rel="stylesheet" type="text/css"/>
    <link href="/templates/hd/assets/css/jsstyle.css" rel="stylesheet" type="text/css"/>

    @endsection
@section('script')

    <script type="text/javascript" src="/templates/hd/assets/js/address.js"></script>
    <script>
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
    </script>

@endsection
@section('content')


    <div class="concent">
        <!--地址 -->
        <div class="paycont">
            <div class="address">
                <h3>确认收货地址 </h3>
                <div class="control">
                    <div class="tc-btn createAddr theme-login am-btn am-btn-danger"><a href="{{route('adress')}}" style="text-decoration:none;
out-line: none;color: #*****;">使用新地址</a></div>
                </div>
                <div class="clear"></div>
                <ul>


                    @foreach($adress as $v)

                    <div class="per-border"></div>
                    <li onclick="gaibian(this)" class="user-addresslist" hd="{{$v['id']}}">

                        <div class="address-left">
                            <div class="user DefaultAddr">

										<span class="buy-address-detail">
                   <span class="buy-user">{{$v['name']}} </span>
										<span class="buy-phone">{{$v['tel']}}</span>
										</span>
                            </div>
                            <div class="default-address DefaultAddr">
                                <span class="buy-line-title buy-line-title-type">收货地址：</span>
                                <span class="buy--address-detail">
								   <span class="province">{{explode('-',$v['adress'])[0]}}</span>省
										<span class="city">{{explode('-',$v['adress'])[1]}}</span>市
										<span class="dist">{{explode('-',$v['adress'])[2]}}</span>区
										<span class="street">{{$v['moreadress']}}</span>
										</span>

                                </span>
                            </div>
                        </div>
                        <div class="address-right">
                            <a href="/templates/hd/assets/person/address.html">
                                <span class="am-icon-angle-right am-icon-lg"></span></a>
                        </div>
                        <div class="clear"></div>

                        <div class="new-addr-btn">
                            <a href="#" class="hidden">设为默认</a>
                            <span class="new-addr-bar hidden">|</span>
                            <a href="{{route('bianji',$v['id'])}}">编辑</a>
                            <span class="new-addr-bar">|</span>
                            <a href="{{route('dell',$v['id'])}}">删除</a>
                        </div>

                    </li>

                    @endforeach


                </ul>

                <div class="clear"></div>
            </div>






            <div class="clear"></div>

            <!--支付方式-->
            <div class="logistics">
                <h3>选择支付方式</h3>
                <ul class="pay-list">
                    <li class="pay qq"><img src="/templates/hd/assets/images/weizhifu.jpg"/>微信<span></span></li>
                </ul>
            </div>
            <div class="clear"></div>
            <script>
                $(".pay").click(function(){
                    $(this).unbind();
                });

            </script>
            <!--订单 -->
            <div class="concent">
                <div id="payTable">
                    <h3>确认订单信息</h3>
                    <div class="cart-table-th">
                        <div class="wp">

                            <div class="th th-item">
                                <div class="td-inner">商品信息</div>
                            </div>
                            <div class="th th-price">
                                <div class="td-inner">单价</div>
                            </div>
                            <div class="th th-amount">
                                <div class="td-inner">数量</div>
                            </div>
                            <div class="th th-sum">
                                <div class="td-inner">金额</div>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>



                        @foreach($card as $v)
                            <tr class="item-list">
                            <div class="bundle  bundle-last">
                                <div class="bundle-main">
                                    <ul class="item-content clearfix">
                                        <div class="pay-phone">
                                            <li class="td td-item">
                                                <div class="item-pic">
                                                    <a href="{{route('detail',$v->good->id)}}" class="J_MakePoint">
                                                        <img src="{{explode(',',$v->good->pics)[0]}}"
                                                             class="itempic J_ItemImg" style="width: 100%;"></a>
                                                </div>
                                                <div class="item-info">
                                                    <div class="item-basic-info">
                                                        <a href="#" class="item-title J_MakePoint"
                                                           data-point="tbcart.8.11">{{$v->good->title}}</a>
                                                    </div>
                                                </div>
                                            </li>
                                            <li class="td td-info">
                                                <div class="item-props">

                                                    @foreach($v->huowu->attrgroup($v->huowu->id) as $vv)
                                                        <span class="sku-line">{{$vv['attr']}}: {{$vv['sonattr']}}</span>
                                                    @endforeach

                                                </div>
                                            </li>
                                            <li class="td td-price">
                                                <div class="item-price price-promo-promo">
                                                    <div class="price-content">
                                                        <em class="J_Price price-now">¥ {{$v->good->mallprice+$v->huowu->fujiaprice}}</em>
                                                    </div>
                                                </div>
                                            </li>
                                        </div>
                                        <li class="td td-amount">
                                            <div class="amount-wrapper ">
                                                <div class="item-amount ">
                                                    <span class="phone-title">购买数量</span>
                                                    <div class="sl">
                                                        <input class="text_box" name="" type="text" value="{{$v['num']}}"
                                                               readonly style="width:30px;"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </li>
                                        <li class="td td-sum">
                                            <div class="td-inner">
                                                <em tabindex="0" class="J_ItemSum number xiaoji">{{$v['xiaoji']}}</em>
                                            </div>
                                        </li>
                                    </ul>
                                    <div class="clear"></div>

                                </div>
                            </div>
                        </tr>
                        @endforeach




                    <div class="clear"></div>
                </div>


            </div>
            <div class="clear"></div>
            <div class="pay-total">
                <!--留言-->
                <div class="order-extra">
                    <div class="order-user-info">
                        <div id="holyshit257" class="memo">
                            <label>买家留言：</label>
                            <input type="text" title="选填,对本次交易的说明（建议填写已经和卖家达成一致的说明）" placeholder="选填,建议填写和卖家达成一致的说明"
                                   class="memo-input J_MakePoint c2c-text-default memo-close">
                            <div class="msg hidden J-msg">
                                <p class="error">最多输入500个字符</p>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <!--含运费小计 -->
            <!--信息 -->
            <div class="order-go clearfix">
                <div class="pay-confirm clearfix">
                    <div class="box">
                        <div tabindex="0" id="holyshit267" class="realPay"><em class="t">实付款：</em>
                            <span class="price g_price ">
                                    <span>¥</span> <em class="style-large-bold-red " id="J_ActualFee">244.00</em>
											</span>
                        </div>

                        <div id="holyshit268" class="pay-address">

                            <p class="buy-footer-address">
                                <span class="buy-line-title buy-line-title-type">寄送至：</span>
                                <span class="buy--address-detail">
								   <span class="province" id="sheng">{{explode('-',$moren['adress'])[0]}}</span>省
												<span class="city" id="shi">{{explode('-',$moren['adress'])[1]}}</span>市
												<span class="dist" id="qu">{{explode('-',$moren['adress'])[2]}}</span>区
												<span class="street" id="more">{{$moren['moreadress']}}</span>
												</span>
                                </span>
                            </p>
                            <p class="buy-footer-address">
                                <span class="buy-line-title">收货人：</span>
                                <span class="buy-address-detail">
                                         <span class="buy-user" id="aidi">{{$moren['name']}} </span>
												<span class="buy-phone" id="phone">{{$moren['tel']}}</span>
												</span>
                            </p>
                        </div>
                    </div>

                    <div id="holyshit269" class="submitOrder">
                        <div class="go-btn-wrap">

                            {{--@if()--}}

                            <a id="J_Go" href="javascript:;" onclick="order()" class="btn-go firstSubmit" tabindex="0" title="点击此按钮，提交订单" style="display: none">提交订单</a>
                            {{--<a href="javascript:;" class="btn-go secondSubmit" tabindex="0" title="点击此按钮，提交订单">提交订单</a>--}}


                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
            </div>
        </div>

        <div class="clear"></div>
    </div>


    <script>

        function gaibian(obj) {
            // alert(123);
            var son = $(obj).find('.buy-user').html()
            // alert(son)
            $('#aidi').html(son)
            // alert(sun)
            var tel = $(obj).find('.buy-phone').html();
            $('#phone').html(tel)

            var  di = $(obj).find('.province').html()
            $('#sheng').html(di);

            var  shi = $(obj).find('.city').html()
            $('#shi').html(shi);

            var  qu = $(obj).find('.dist').html()
            $('#qu').html(qu);

            var  more = $(obj).find('.street').html()
            $('#more').html(more)

            $('.secondSubmit').hide();
            $('.firstSubmit').show();
        }
        $(function () {
            zongjia();
        });

        function zongjia() {
            var total = 0;
            $.each($('.xiaoji'), function (k, v) {
                total += $(v).html() * 1;
            })
            $('#J_ActualFee').html(total);
        }

        // alert(12);

        // 提交订单发送异步
        function order() {
            // 获得总价往表里填
            var zongjia = $('#J_ActualFee').html();
            // 获得地址id到时候往数据表里填
            var addressid = $('.defaultAddr').attr('hd');


            $.ajax({
                url:'/suborder',
                type:'post',
                data:{total: zongjia, addressid: addressid},
                dataType:'json',
                success:function (res) {
                    // 支付成功跳到支付成功页面
                    if (res.volid){


                        location.href = '/pay/'+res.data;
                        // console.log(res.data)


                    }
                }
            })
        }



    </script>
@endsection